package com.sc.nft.mapper;

import com.sc.nft.entity.UserMarketValue;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
/**
 * 用户市值表(sc_user_market_value)数据Mapper
 *
 * @author zxy
 * @description 用户市值
 * @since 2023-07-21 00:27:15
 */
@Mapper
public interface UserMarketValueMapper extends BaseMapper<UserMarketValue> {

    @Update("truncate table sc_user_market_value")
    void truncate();


    @Insert("insert into sc_user_market_value_history (" +
            "user_id," +
            "yesterday_market_value," +
            "smelt_market_value," +
            "record_time," +
            "create_time," +
            "modify_time," +
            "create_id," +
            "modify_id," +
            "is_delete" +
            ") select user_id," +
            "yesterday_market_value," +
            "smelt_market_value," +
            "record_time," +
            "create_time," +
            "modify_time," +
            "create_id," +
            "modify_id," +
            "is_delete from sc_user_market_value")
    void history();

    void init();

    BigDecimal getMarketValue(@Param("userId") Long userId, @Param("expectUserIds") List<Long> expectUserIds);
    BigDecimal getTheTotalPerformanceOfTheUserTeam(@Param("userId") Long userId, @Param("day") Integer day, @Param("urbanServiceCenter") Boolean urbanServiceCenter);
    /**
     * 获取用户在熔炼中的持仓成本
     *
     * @param userId
     * @return
     */
    BigDecimal getUserSmeltCost(@Param("userId") Long userId);
    BigDecimal getEcologyMarketValue(@Param("userId") Long userId, @Param("expectUserIds") List<Long> expectUserId);
    /**
     * 获取用户持仓金额大于多少的用户数量
     * @param userIds
     * @param position
     * @return
     */
    Integer getUserIdsCount(@Param("userIds") List<Long> userIds, @Param("position") BigDecimal position);
    /**
     * 团队藏品持仓总额
     * @param userIds
     * @return
     */
    BigDecimal getUserIdsYesterdayMarketValue(@Param("userIds") List<Long> userIds);
    /**
     * 团队生态熔炼市值总额
     * @param userIds
     * @return
     */
    BigDecimal getUserIdsSmeltMarketValue(@Param("userIds") List<Long> userIds);
}
